/* eslint valid-jsdoc: "off" */

'use strict';

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1609153015672_9391';

  // add your middleware config here
  config.middleware = [];

  config.sequelize = {
    dialect: 'mysql',
    database: 'book',
    host: 'localhost',
    port: 3306,
    username: 'root',
    password: '123456',
    timezone: '+08:00',
  }

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };

  config.cors = {
    origin: "*",
    allowMethods: "GEI,HEAD,PUT,POST,DELETE,PATCH"
  }

  config.jwt = {
    secret: "book"
  };

  config.security = {
    csrf: {
      enable: false
    }
  }

  // 设置路由白名单
  config.routerAuth = ["/login","/indexUser?username=","/user"]

  // 中间件执行顺序是按照数组中的顺序执行
  config.middleware = ["auth"]

  return {
    ...config,
    ...userConfig,
  };
};
